<template>
	<view>
		<view class="bg">
		</view>
		<view class="middle_wrapper">
			<view class="border">
				<view class="middle borderB">
					<view class="title">
						<image src="../../../../static/image/feedback1.png" mode=""></image>
						<view class="text">
							反馈内容
						</view>
					</view>
					<view class="textarea">
						<textarea v-model="value" placeholder="请填写10字以上的问题描述，以便我们更好的帮助您解决问题。" />
					</view>
				</view>
				<view class="middle">
				<view class="title">
					<image src="../../../../static/image/upload.png" mode=""></image>
					<view class="text">
						上传凭证
					</view>
				</view>
				<view class="imageList">
					<view class="image" v-for="(item,index) in imageList" :key="index">
						<image :src="item" mode=""></image>
						<view class="cha" @click="remove(index)">
							<image src="../../../../static/image/guanbi-@2x.png" mode=""></image>
						</view>
					</view>
					<view class="upload" @click="toUpload">
						<image src="../../../../static/image/zhaoxiangji@2x.png" mode=""></image>
					</view>
				</view>
			</view>
			</view>
		</view>
		<view class="btn" @click="toCun">
			<button>保存</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value:"",
				imageList:[]
			}
		},
		methods: {
			toUpload(){
				uni.chooseImage({
				    count: 9, //默认9
				    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
				    sourceType: ['album'], //从相册选择
				    success:(res)=> {
				       this.imageList.push(...res.tempFilePaths)
				    }
				});
			},
			remove(index){
				this.imageList.splice(index,1)
			},
			async toCun(){
				let token=uni.getStorageSync("token")
				let image=this.imageList.join(",")
				if(!token){
					uni.navigateTo({
						url:"/pages/login/login"
					})
					uni.showToast({
						title:"请先登录",
						icon:"error"
					})
					return
				}
				const {data}=await this.$http({
					url:"member/feedback",
					header:{
						"token":token
					},
					data:{
						"content":this.value,
						"imgs":image
					}
				})
				uni.navigateBack({
					delta:1
				})
				uni.showToast({
					title:data.msg,
				})
			}
		}
	}
</script>

<style scoped>
.bg{
	position: fixed;
	width: 100%;
	height: 100%;
	left: 0;
	top: 0;
	background-color: #F1F1F1;
	z-index: -1;
}
.middle_wrapper{
	padding: 30rpx;
}
.middle{
	background-color: #FFFFFF;
	padding: 20rpx;
	padding-top: 5rpx;
}
.title{
	display: flex;
	align-items: center;
	margin-top: 30rpx;
}
.title .text{
	margin-left: 15rpx;
	font-size: 32rpx;
	font-family: PingFang SC;
	font-weight: 550;
	color: #333333;
}
.title image{
	width: 30rpx;
	height: 30rpx;
}
.textarea{
	height: 274rpx;
	background: #F1F1F1;
	border: 1rpx solid #EAEAEA;
	border-radius: 6rpx;
	padding: 10rpx;
	margin-top: 30rpx;
}
.borderB{
	border-bottom: 1px solid #EAEAEA;
	padding-bottom: 40rpx;
}
.border{
	border-radius: 10rpx !important;
}
.upload{
	width: 120rpx;
	height: 120rpx;
	border: 2rpx solid #BFBFBF;
	border-radius: 6rpx;
	margin-left: 20rpx;
	position: relative;
}
.upload image{
	width: 33rpx;
	height: 28rpx;
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%,-50%);
}
.imageList{
	margin-top: 30rpx;
	display: flex;
	flex-wrap: wrap;
}
.imageList .cha{
	position: absolute;
	right: -18rpx;
	top: -18rpx;
}
.imageList .cha image{
	width: 36rpx;
	height: 36rpx;
}
.image{
	margin-left: 20rpx;
	position: relative;
}
.image image{
	width: 120rpx;
	height: 120rpx;
	/* border: 2rpx solid #BFBFBF; */
	border-radius: 6rpx;
}
.btn{
	position: fixed;
	bottom: 5%;
	left: 50%;
	transform: translate(-50%,0);
}
.btn button{
	width: 690rpx;
	height: 80rpx;
	background: #F7CC46;
	border-radius: 40rpx;
	font-size: 32rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #FDFBFB;
}
</style>
